package com.example.databasedoc.enums;

import cn.smallbun.screw.core.engine.EngineFileType;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;

/**
 * FileTypeEnum
 *
 * @author lijunsong
 * @date 2021/4/26 19:24
 * @since 1.0
 */
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum FileTypeEnum {
    /**
     * 数据表文件类型
     */
    HTML("html", EngineFileType.HTML),
    WORD("word", EngineFileType.WORD),
    MD("md", EngineFileType.MD);
    @Getter
    private String key;
    @Getter
    private EngineFileType value;

    FileTypeEnum(String key, EngineFileType value) {
        this.key = key;
        this.value = value;
    }

    @JsonCreator
    public static FileTypeEnum fromKey(String key) {
        for (FileTypeEnum s : FileTypeEnum.values()) {
            if (s.key.equals(key)) {
                return s;
            }
        }
        return HTML;
    }
}
